package com.wangy.controller;

import com.wangy.bean.SqlQuery;
import com.wangy.service.ExecuteSQLService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * *@Author yyzb
 * *@Date 2024/10/27 15:29
 * *@Version 1.0
 */

@RestController
@RequestMapping("/report")
public class ExecuteSQLController {

    @Autowired
    ExecuteSQLService executeSQLService;


    @PostMapping("createClickHouseTable")
    public String createClickHouseTable(@RequestBody SqlQuery sqlQuery) throws Exception {
        return executeSQLService.executeMySQL(sqlQuery.getSql());
    }

    @PostMapping("createMySQLTable")
    public String createMySQLTable(@RequestBody SqlQuery sqlQuery) throws Exception {
        return executeSQLService.executeClickhouse(sqlQuery.getSql());
    }
}
